<?php if(!defined("HDPHP_PATH"))exit;C("SHOW_NOTICE",FALSE);?><!doctype html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>添加商品</title>
	 <link rel="stylesheet" href="http://localhost/Gshop/Gshop/Gshop/Admin/Tpl/Public/css/index.css">
  <script src="http://localhost/Gshop/Gshop/Gshop/Admin/Tpl/Public/js/jquery-1.7.2.min.js"></script>
  <script src="http://localhost/Gshop/Gshop/Gshop/Admin/Tpl/Public/js/js.js"></script>
            <style>     
           #add{
                color:red;
                cursor:pointer;
                height:100px;
           }
           .bac{
               background:#F3F3F3;
           }
           #close{
            cursor:pointer;
            color:red;
           }
           .img{
              float: left;
              margin-left:10px;
              margin-bottom:10px;
              position: relative;
           }
           .wrapImg{
              overflow: hidden;
           }
           .close{
              position: absolute;
              top:5px;
              right:5px;
              color:red;
              cursor:pointer;
              font-weight: 700;
              display: block;

           }
             .guige{
            cursor:pointer;
           }

      </style>
      <script type="text/javascript" src="http://localhost/Gshop/Gshop/Gshop/Admin/Tpl/Goods/js/js.js"></script>
</head>
<body>
	<form method="post" enctype="multipart/form-data" class="form">
		<input type="hidden" name="gid" value="<?php echo $_GET['gid'];?>">
            <input type="hidden" name="cid" value="<?php echo $_GET['cid'];?>">
		<div class="wrap">
			<div class="menu_list">
				<ul>
				<li>
					<a href="<?php echo U(index);?>">商品列表</a>
				</li>
				<li>
					<a href="" class="action">添加商品</a>
				</li>
			        </ul>
			</div>

			<div class="tab">
				<ul>
					<li class="btn1 w100 action">
				        基本信息
					</li>
					<li class="btn1 w100">
						详细内容
					</li>
					<li class="btn1 w100">
						图片
					</li>
				</ul>

			<div class="tab-content">	
				<!-- 基本信息 -->
                                    	<table class="table2" >
                                    		<tr>
                                    			<th class="w150">名称</th>
                                    			<td >
                                    				<input type="text" name="gname" id="" class="w300" value="<?php echo $data['gname'];?>">
                                    			</td>
                                    		</tr>
                                    		<tr>
                                    			<th class="w150">属性</th>
                                    			<td >
                                    				<label>置顶<input type="checkbox" name="flag[]" id="" value="置顶" <?php if(strstr($data[flag],置顶)){?>checked=""<?php }?>></label>
                                    				<label>推荐<input type="checkbox" name="flag[]" id="" value="推荐" <?php if(strstr($data[flag],推荐)){?>checked=""<?php }?>></label>
                                    			</td>
                                    		</tr>
                                    		<tr>
                                    			<th class="w150">栏目</th>
                                    		      <td>
                                                   <?php $hd["list"]["cate"]["total"]=0;if(isset($category) && !empty($category)):$_id_cate=0;$_index_cate=0;$lastcate=min(1000,count($category));
$hd["list"]["cate"]["first"]=true;
$hd["list"]["cate"]["last"]=false;
$_total_cate=ceil($lastcate/1);$hd["list"]["cate"]["total"]=$_total_cate;
$_data_cate = array_slice($category,0,$lastcate);
if(count($_data_cate)==0):echo "";
else:
foreach($_data_cate as $key=>$cate):
if(($_id_cate)%1==0):$_id_cate++;else:$_id_cate++;continue;endif;
$hd["list"]["cate"]["index"]=++$_index_cate;
if($_index_cate>=$_total_cate):$hd["list"]["cate"]["last"]=true;endif;?>

                                                      <?php if($cate['cid'] == $data['cid']){?><?php echo $cate['_name'];?><?php }?>
                                                   <?php $hd["list"]["cate"]["first"]=false;
endforeach;
endif;
else:
echo "";
endif;?>  
                                              </td>
                                    		 </tr>
                                         <!-- 商品普通属性 -->
                                          <tr>
                                              <th class="w150">商品属性类型</th>
                                                <td>
                                                  <table>
                                                   <?php $hd["list"]["GoodsAttr"]["total"]=0;if(isset($GoodsAttrData) && !empty($GoodsAttrData)):$_id_GoodsAttr=0;$_index_GoodsAttr=0;$lastGoodsAttr=min(1000,count($GoodsAttrData));
$hd["list"]["GoodsAttr"]["first"]=true;
$hd["list"]["GoodsAttr"]["last"]=false;
$_total_GoodsAttr=ceil($lastGoodsAttr/1);$hd["list"]["GoodsAttr"]["total"]=$_total_GoodsAttr;
$_data_GoodsAttr = array_slice($GoodsAttrData,0,$lastGoodsAttr);
if(count($_data_GoodsAttr)==0):echo "";
else:
foreach($_data_GoodsAttr as $key=>$GoodsAttr):
if(($_id_GoodsAttr)%1==0):$_id_GoodsAttr++;else:$_id_GoodsAttr++;continue;endif;
$hd["list"]["GoodsAttr"]["index"]=++$_index_GoodsAttr;
if($_index_GoodsAttr>=$_total_GoodsAttr):$hd["list"]["GoodsAttr"]["last"]=true;endif;?>

                                                    <tr>
                                                      <th><?php echo $GoodsAttr['attr_name'];?></th>
                                                      <td><?php echo $GoodsAttr['html'];?></td>
                                                    </tr>
                                                   <?php $hd["list"]["GoodsAttr"]["first"]=false;
endforeach;
endif;
else:
echo "";
endif;?>
                                                    </table>
                                                </td>
                                            </tr>
                                            <!-- 商品属性结束 -->

                                            <!-- 商品规格 -->
                                             <tr>
                                              <th class="w150">商品属性规格</th>
                                                <td>
                                                  <table>
                                                    <tr align="center">
                                                      <?php $hd["list"]["GoodSpec"]["total"]=0;if(isset($GoodSpecData[0][name]) && !empty($GoodSpecData[0][name])):$_id_GoodSpec=0;$_index_GoodSpec=0;$lastGoodSpec=min(1000,count($GoodSpecData[0][name]));
$hd["list"]["GoodSpec"]["first"]=true;
$hd["list"]["GoodSpec"]["last"]=false;
$_total_GoodSpec=ceil($lastGoodSpec/1);$hd["list"]["GoodSpec"]["total"]=$_total_GoodSpec;
$_data_GoodSpec = array_slice($GoodSpecData[0][name],0,$lastGoodSpec);
if(count($_data_GoodSpec)==0):echo "";
else:
foreach($_data_GoodSpec as $key=>$GoodSpec):
if(($_id_GoodSpec)%1==0):$_id_GoodSpec++;else:$_id_GoodSpec++;continue;endif;
$hd["list"]["GoodSpec"]["index"]=++$_index_GoodSpec;
if($_index_GoodSpec>=$_total_GoodSpec):$hd["list"]["GoodSpec"]["last"]=true;endif;?>

                                                         <td><?php echo $GoodSpec['name'];?></td>
                                                      <?php $hd["list"]["GoodSpec"]["first"]=false;
endforeach;
endif;
else:
echo "";
endif;?>
                                                      <td>库存</td>
                                                      <td>价格</td>
                                                      <td>货号</td>
                                                      <td>操作</td>
                                                    </tr>
                                                  <tbody>
                                                       <?php $hd["list"]["GoodSpec"]["total"]=0;if(isset($GoodSpecData) && !empty($GoodSpecData)):$_id_GoodSpec=0;$_index_GoodSpec=0;$lastGoodSpec=min(1000,count($GoodSpecData));
$hd["list"]["GoodSpec"]["first"]=true;
$hd["list"]["GoodSpec"]["last"]=false;
$_total_GoodSpec=ceil($lastGoodSpec/1);$hd["list"]["GoodSpec"]["total"]=$_total_GoodSpec;
$_data_GoodSpec = array_slice($GoodSpecData,0,$lastGoodSpec);
if(count($_data_GoodSpec)==0):echo "";
else:
foreach($_data_GoodSpec as $key=>$GoodSpec):
if(($_id_GoodSpec)%1==0):$_id_GoodSpec++;else:$_id_GoodSpec++;continue;endif;
$hd["list"]["GoodSpec"]["index"]=++$_index_GoodSpec;
if($_index_GoodSpec>=$_total_GoodSpec):$hd["list"]["GoodSpec"]["last"]=true;endif;?>

                                                        <tr class="one">
                                                           <?php $hd["list"]["Spec"]["total"]=0;if(isset($GoodSpec['html']) && !empty($GoodSpec['html'])):$_id_Spec=0;$_index_Spec=0;$lastSpec=min(1000,count($GoodSpec['html']));
$hd["list"]["Spec"]["first"]=true;
$hd["list"]["Spec"]["last"]=false;
$_total_Spec=ceil($lastSpec/1);$hd["list"]["Spec"]["total"]=$_total_Spec;
$_data_Spec = array_slice($GoodSpec['html'],0,$lastSpec);
if(count($_data_Spec)==0):echo "";
else:
foreach($_data_Spec as $key=>$Spec):
if(($_id_Spec)%1==0):$_id_Spec++;else:$_id_Spec++;continue;endif;
$hd["list"]["Spec"]["index"]=++$_index_Spec;
if($_index_Spec>=$_total_Spec):$hd["list"]["Spec"]["last"]=true;endif;?>

                                                             <td><?php echo $Spec['spec'];?></td>
                                                           <?php $hd["list"]["GoodSpec"]["first"]=false;
endforeach;
endif;
else:
echo "";
endif;?>
                                                       <td>
                                                        <input type="text" value="<?php echo $GoodSpec['stock'];?>" name="stock[]" id="">
                                                      </td>
                                                      <td>
                                                        <input type="text" value="<?php echo $GoodSpec['price'];?>" name="price[]" id="">
                                                      </td>
                                                      <td>
                                                        <input type="text" value="<?php echo $GoodSpec[goods_sn];?>" name="goods_sn[]" id="">
                                                      </td>
                                                      <td align="center">
                                                         <span class="guige" onclick="addSpec(this)" >加（+）</span>
                                                      </td>
                                                    </tr>
                                                    <?php $hd["list"]["Spec"]["first"]=false;
endforeach;
endif;
else:
echo "";
endif;?>
                                                   
                                                  </tbody>
                                                
                                                    </table>
                                                </td>
                                            </tr>
                                      <!-- 商品规格结束 -->
                                                 <tr>
                                                      <th class="w150">品牌</th>
                                                      <td >
                                                            <select name="brandid" id="">
                                                                  <option value="">==请选择==</option>
                                                                      <?php $hd["list"]["bra"]["total"]=0;if(isset($brand) && !empty($brand)):$_id_bra=0;$_index_bra=0;$lastbra=min(1000,count($brand));
$hd["list"]["bra"]["first"]=true;
$hd["list"]["bra"]["last"]=false;
$_total_bra=ceil($lastbra/1);$hd["list"]["bra"]["total"]=$_total_bra;
$_data_bra = array_slice($brand,0,$lastbra);
if(count($_data_bra)==0):echo "";
else:
foreach($_data_bra as $key=>$bra):
if(($_id_bra)%1==0):$_id_bra++;else:$_id_bra++;continue;endif;
$hd["list"]["bra"]["index"]=++$_index_bra;
if($_index_bra>=$_total_bra):$hd["list"]["bra"]["last"]=true;endif;?>

                                                                        <option value="<?php echo $bra['bid'];?>" <?php if($bra['bid'] == $data['brandid']){?>selected=""<?php }?>><?php echo $bra['bname'];?></option>
                                                                      <?php $hd["list"]["bra"]["first"]=false;
endforeach;
endif;
else:
echo "";
endif;?>
                                                            </select>
                                                      </td>
                                                 </tr>
                                               
                                    		  <tr>
                                    		 	<th class="w150">关键字</th>
                                    		          <td>
                                    		          	<input type="text" value="<?php echo $data['keywords'];?>" name="keywords" id="" class="w300">
                                    		          </td>
                                    		 </tr>
                                    		   <tr>
                                    		 	<th class="w150">描述</th>
                                    		          <td>
                                    		          	<textarea name="description" id="" cols="30" rows="10" class="w400 h100"><?php echo $data['description'];?></textarea>
                                    		          </td>
                                    		 </tr>
                                    	</table>
                                </div>
                                    <!-- 详细信息 -->
                                    <div class="tab-content" >
                                    	<table class="table2" >
                                    		<tr>
                                    			<th class="w150">内容</th>
                                    			<td >
                                    				<script type="text/javascript" charset="utf-8" src="http://localhost/Gshop/hdphp/hdphp/Extend/Org/Ueditor/ueditor.config.js"></script><script type="text/javascript" charset="utf-8" src="http://localhost/Gshop/hdphp/hdphp/Extend/Org/Ueditor/ueditor.all.min.js"></script><script type="text/javascript">UEDITOR_HOME_URL="http://localhost/Gshop/hdphp/hdphp/Extend/Org/Ueditor/"</script><script id="hd_body" name="body" type="text/plain"><?php echo $data['body'];?></script>
        <script type='text/javascript'>
        $(function(){
                var ue = UE.getEditor('hd_body',{
                imageUrl:'http://localhost/Gshop/index.php?a=Admin&c=Goods&gid=41&cid=20&m=ueditor_upload&g=Gshop&water=0&uploadsize=2000000&maximagewidth=false&maximageheight=false'//处理上传脚本
                ,zIndex : 0
                ,autoClearinitialContent:false
                ,initialFrameWidth:"100%" //宽度1000
                ,initialFrameHeight:"300" //宽度1000
                ,autoHeightEnabled:false //是否自动长高,默认true
                ,autoFloatEnabled:false //是否保持toolbar的位置不动,默认true
                ,maximumWords:2000 //允许的最大字符数
                ,readonly : false //编辑器初始化结束后,编辑区域是否是只读的，默认是false
                ,wordCount:true //是否开启字数统计
                ,imagePath:''//图片修正地址
                , toolbars:[
            ['fullscreen', 'source', '|', 'undo', 'redo', '|',
                'bold', 'italic', 'underline', 'fontborder', 'strikethrough', 'superscript', 'subscript', 'removeformat', 'formatmatch', 'autotypeset', 'blockquote', 'pasteplain', '|', 'forecolor', 'backcolor', 'insertorderedlist', 'insertunorderedlist', 'selectall', 'cleardoc', '|',
                'rowspacingtop', 'rowspacingbottom', 'lineheight', '|',
                'customstyle', 'paragraph', 'fontfamily', 'fontsize', '|',
                'directionalityltr', 'directionalityrtl', 'indent', '|',
                'justifyleft', 'justifycenter', 'justifyright', 'justifyjustify', '|', 'touppercase', 'tolowercase', '|',
                'link', 'unlink', 'anchor', '|', 'imagenone', 'imageleft', 'imageright', 'imagecenter', '|',
                'insertimage', 'emotion', 'scrawl', 'insertvideo', 'music', 'attachment', 'map', 'gmap', 'insertframe','insertcode', 'pagebreak', 'template', 'background', '|',
                'horizontal', 'date', 'time', 'spechars',  'wordimage', '|',
                'inserttable', 'deletetable', 'insertparagraphbeforetable', 'insertrow', 'deleterow', 'insertcol', 'deletecol', 'mergecells', 'mergeright', 'mergedown', 'splittocells', 'splittorows', 'splittocols', 'charts', '|',
                'print', 'preview', 'searchreplace']
            ]//工具按钮
                , initialStyle:'p{line-height:1em; font-size: 14px; }'
            });
        })
        </script>
                                    			</td>
                                    		</tr>
                                    		<tr>
                                    			<th class="w150">服务</th>
                                    			<td >
                                    				<input type="text" value="<?php echo $data['service'];?>" name="service" id="" class="w300">
                                    			</td>
                                    		</tr>
                                    		<tr>
                                    			<th class="w150">查看次数</th>
                                    			<td >
                                    				<input type="text" value="<?php echo $data['click'];?>" name="click" id="" class="w300">
                                    			</td>
                                    		</tr>
                                                  <tr>
                                                                  <th class="w150">更新时间</th>
                                                                  <td >
                                                                        <input type="text" name="addtime" id="addtime" class="w300" readonly="readonly"   value="<?php echo date('Y/m/d h:i:s');?>">
                                                                  </td>
                                                      </tr>
                                    	</table>
                                    </div>
                                    <div class='tab-content'>
                                    	<table class="table2">
                                    		<tr>
                                    			<th>首页图</th>
                                    			<td>
         
                                    				<input type="file" name="index_pic" id="" >
                                    				<img src="http://localhost/Gshop/<?php echo $data['index_pic'];?>" alt="" class="w50 h50 m10">
                                    				<input type="hidden" name="index_pic" value="<?php echo $data['index_pic'];?>">
                                    				
                                    			</td>
                                    		</tr>
                                    		<tr>
                                    			<th>列表图</th>
                                    			<td>
                                    				<input type="file" name="list_pic" id="">
                                    				<img src="http://localhost/Gshop/<?php echo $data['list_pic'];?>" alt="" class="w50 h50 m10">
                                    				<input type="hidden" name="list_pic" value="<?php echo $data['list_pic'];?>">
                                    			</td>
                                    		</tr>
                                                            <tr>
                                                                  <th>内容图</th>
                                                                  <td id="td" >
                                                                        <div class="wrapImg">
                                                                              <?php $hd["list"]["p"]["total"]=0;if(isset($pic) && !empty($pic)):$_id_p=0;$_index_p=0;$lastp=min(1000,count($pic));
$hd["list"]["p"]["first"]=true;
$hd["list"]["p"]["last"]=false;
$_total_p=ceil($lastp/1);$hd["list"]["p"]["total"]=$_total_p;
$_data_p = array_slice($pic,0,$lastp);
if(count($_data_p)==0):echo "";
else:
foreach($_data_p as $key=>$p):
if(($_id_p)%1==0):$_id_p++;else:$_id_p++;continue;endif;
$hd["list"]["p"]["index"]=++$_index_p;
if($_index_p>=$_total_p):$hd["list"]["p"]["last"]=true;endif;?>

                                                                                    <div class="img">
                                                                                <img src="http://localhost/Gshop/<?php echo $p['medium'];?>"  class="w100 h100">
                                                                                <span class="close" id="<?php echo $p['pic_id'];?>">X</span>
                                                                                    </div>

                                                                              <?php $hd["list"]["p"]["first"]=false;
endforeach;
endif;
else:
echo "";
endif;?>
                                                                        </div>

                                                                        <div class="content">
                                                                              <input type="file" name="pic[]" id="" class="w150">
                                                                           <span id="add" >增加（+）</span>
                                                                        </div>
                                                                  </td>
                                                            </tr>
                                    	</table>
                                    </div>
	</div>
		<!-- 底部确定按钮 -->
	<div class="position-bottom">
                     <input type="submit" value="确定" class="btn">
                    </div>
	</form>
</body>
<script>

      $("#addtime").calendar({format: 'yyyy/MM/dd HH:mm:ss'});
      var input="<div style='margin-top:10px' class='content'><input type='file' name='pic[]' id= class='w150' class='w150' ><span style='color:red;margin-left:5px;cursor:pointer'  class='del1'>减少（-）<span></div>";
      $("#add").click(function(){
            $("#td").append(input);
      })
      $(".del1").live("click",function(){
            $(this).parent().remove();
      })
      $(".content").live("hover",function(){
            $(this).addClass('bac').siblings('.content').removeClass('bac');
      })

</script>
<script>
      $(function(){
      $(".close").click(function(){
            var pic_id=$(this).attr("id");
            var _this=$(this);
            $.post("?m=delContentPic",{pic_id:pic_id},function(data){
                   if(data==1){
                        $(_this).parent().remove();
                   }else{
                       alert("删除失败");
                   }
            })
      })
})

//改变规格添加按钮的样式（除了第一个是加，其余的是减）
$(".guige:gt(0)").text("减（-）");
$(".guige:gt(0)").removeAttr("onclick");
</script>
</html>








